package 补充数组;

import java.util.Arrays;

public class 二维数组输出最大值 {
    public static void main(String[] args) {

        //定义一个二维数组
        int[][] b = new int[5][5];
        for (int i = 0; i < b.length; i++) {
            for (int j = 0; j < (b[i]).length; j++) {
                b[i][j] = (int) (Math.random() * 100);
            }
        }

        System.out.println("for循环输出一个5*5的二维数组：");
        for (int i = 0; i < b.length; i++) {
            for (int j = 0; j < (b[i]).length; j++) {
                System.out.print(b[i][j] + "\t");
            }
            System.out.println();//换行
        }

        //这也是二维数组输出语句
        System.out.println("array.toString输出二维数组：");
        for (int i = 0; i < b.length; i++) {
            System.out.println(Arrays.toString(b[i]));
        }

        int temp = 0;
        int ii = 0;
        int jj = 0;
        int i;
        int j = 0;
        for (i = 0; i < b.length; i++) {
            for (j = 0; j < (b[i]).length; j++) {
                if (b[i][j] > temp) {
                    temp = b[i][j];
                    ii = i;
                    jj = j;
                }
            }

        }
        System.out.println("该二维数组最大值为：" + temp);
        System.out.println(temp + "的坐标是：" + ii + '，' + jj);


    }
}
